<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script>
    <%--var itemClass = "";--%>
    <%--$(function(){--%>
        <%--itemClass = $("#orderClass").val();--%>
        <%--if(itemClass == 'A'){--%>
            <%--autoCompleteDrug("orderText");--%>
        <%--}--%>
    <%--})--%>
    <%--/*药品自动补全*/--%>
    <%--function autoCompleteDrug(inputId) {--%>
        <%--$("#"+inputId).flushCache();            //刷新缓存（非常重要）--%>
        <%--$("#clinicItemId").val("");--%>
        <%--$("#orderClass").val("");--%>
        <%--$('#singleDoseUnit').val("");//最小单位--%>
        <%--$('#packageSpec').val("");//包装规格--%>
        <%--$('#firmId').val("");--%>
        <%--$('#firmName').val("");--%>
        <%--var url = "${ctx}/orders/orders/autoComplete";--%>
        <%--autoComplete(inputId, url,--%>
                <%--function (data) {--%>
                    <%--var rows = [];--%>
                    <%--for (var i = 0; i < data.length; i++) {--%>
                        <%--rows[rows.length] = {--%>
                            <%--data: data[i],--%>
                            <%--value: data[i].price_id,--%>
                            <%--result: data[i].drug_name--%>
                        <%--};--%>
                    <%--}--%>
                    <%--return rows;--%>
                <%--}, function (data, i, max) {--%>
                    <%--console.info(data);--%>
                    <%--return data.drug_name + "|" + data.package_spec + "|" +data.packageunit + "|" + data.min_spec + "|" + data.minunits + "|" + data.price + "元 |" + data.firm_name + "|库存量：" + data.quantity;--%>
                <%--}, function (event, data, formatted) {--%>
                    <%--$("#clinicItemId").val(data.price_id);--%>
                    <%--$("#orderClass").val(data.durg_class);--%>
                    <%--$('#singleDoseUnits').val(data.dose_per_unit);//最小单位--%>
                    <%--$('#singleDoseUnit').val(data.min_units);--%>
                    <%--$('#packageSpec').val(data.package_spec);//包装规格--%>
                    <%--$('#firmId').val(data.firm_id);--%>
                    <%--$('#firmName').val(data.firm_name);--%>
                    <%--$('#price').val(data.price);--%>
                <%--})--%>
    <%--}--%>

    /*选择价表自动补全*/
    autoCompleteDrug("orderText");
    function autoCompleteDrug(inputId){
        var storageId = $("#applyTableId .table-selected").find("td").eq(7).text();
        var url="${ctx}/doctor/prescriptionItem/autoComplete?drugClass=A&storageId="+storageId;
        autoComplete(inputId,url,
                function(data){
                    var rows = [];
                    for(var i=0; i<data.length; i++){
                        rows[rows.length] = {
                            data:data[i],
                            value:data[i].priceId,
                            result:data[i].drugName
                        };
                    }
                    return rows;
                },function(data, i, max){
                    return data.inputCode+"|"+data.drugName+"|  "+data.packageSpec+"|  "+data.packageUnit+"|  "+data.price+"元 |  "+data.firmName+"|库存量："+data.quantity;
                },function(event,data,formatted){

                    $('#orderCode').attr('value',data.drugCode);
                    $('#drugNameId').attr('value',data.drugName);
                    $('#singleDosage').attr('value',data.dosePerUnit);
                    $('#singleUnit').attr('value',data.doseUnits);
                    $('#singleDoseUnit').attr('value',data.doseUnits);
                    $('#firmName').attr('value',data.firmName);
                    $('#firmId').attr('value',data.firmId);
                    $('#price').attr('value',data.price);
                    $('#packageSpec').attr('value',data.packageSpec);
                    $('#packUnit').attr('value',data.packageUnit);
                    $('#drugUnits').attr('value',data.packUnit);
                    $('#sumPrice').attr('value',data.price);
                    $('#unit').attr('value',data.minUnits);
                    $('#minUnitsTranslate').attr('value',data.minUnitsTranslate);
                    $('#spec').attr('value',data.minSpec);
                    $('#inputCode').attr('value',data.inputCode);
                    $('#priceId').attr('value',data.priceId);
                    $('#sumPrice').attr('value',0);
                })
    }

    $(function(){
        $("#btnCancel").on('click',function(){
            showDiv();
        })

        $("#amount").change(function(){
            var num=$(this).val();
            var price=$("#price").val();
            $("#sumPrice").val(num*price);
        })
    })
</script>





<div class="content-wrap">
    <section class="panel panel-default">
        <div class="panel-body">
            <div class="col-lg-12">
                <form:form id="inputForm" data-parsley-validate="" modelAttribute="treatProjectItem" method="post"
                           class="form-horizontal">
                    <form:hidden path="id"/>
                    <form:hidden path="orderCode"/>
                    <form:hidden path="clinicItemId"/>
                    <form:hidden path="drugUnits"/>
                    <form:hidden path="orderClass" value="${doctorTempla.itemClass}"/>
                    <form:hidden path="performedBy"/>
                    <form:hidden path="newDept" value="${doctorTempla.billingDept}"/>
                    <form:hidden path="firmId"/>
                    <form:hidden path="repeatIncaditor" value="${doctorTempla.repeatIndiractor}"/>
                    <form:hidden path="parent.id" id="parentId"/>
                    <form:hidden path="applyId" value="${treatProjectItem.applyId}"/>
                    <form:hidden path="priceId" value="${treatProjectItem.priceId}"/>
                    <form:hidden path="spec" value="${treatProjectItem.spec}"/>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">处方内容：</label>

                        <div class="col-sm-8">
                            <form:input path="orderText" htmlEscape="false" class="form-control" maxlength="64"/>
                        </div>
                    </div>
                    <%--<div class="form-group">--%>
                        <%--<label class="col-sm-4 control-label">项目代码：</label>--%>

                        <%--<div class="col-sm-8">--%>
                            <%--<form:input path="orderCode" readonly="true" htmlEscape="false" class="form-control"--%>
                                        <%--maxlength="64"/>--%>
                        <%--</div>--%>
                    <%--</div>--%>

                    <div class="form-group">
                        <label class="col-sm-4 control-label">单次剂量：</label>

                        <div class="col-sm-8">
                            <form:input path="singleDose" id="singleDose" data-parsley-required="true" htmlEscape="false" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">计量单位：</label>

                        <div class="col-sm-8">
                            <form:input path="singleDoseUnit"  id="singleDoseUnit" htmlEscape="false" readonly="true" class="form-control" maxlength="5"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">包装规格：</label>

                        <div class="col-sm-8">
                            <form:input path="packageSpec" id="packageSpec" htmlEscape="false" readonly="true" class="form-control" maxlength="64"/>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-4 control-label">频次：</label>

                        <div class="col-sm-8">
                            <form:select path="performFreq" id="performFreq"  data-parsley-required="true" class="form-control" itemLabel="freqDesc" itemValue="id">
                                <form:option value="" label="请选择执行频次"/>
                                <form:options items="${fns:findFreqList()}" itemLabel="freqDesc" itemValue="id"
                                              htmlEscape="false"/>
                            </form:select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label">途径：</label>

                        <div class="col-sm-8">
                            <form:select path="administration" data-parsley-required="true" id="administration" class="form-control">
                                <form:option value="" label="请选择用药途径"/>
                                <form:options items="${fns:getSysDictList('ADMINISTRATION_DICT')}" itemLabel="label"
                                              itemValue="id" htmlEscape="false"/>
                            </form:select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label">厂商：</label>

                        <div class="col-sm-8">
                            <form:input path="firmName" htmlEscape="false" readonly="true" class="form-control" maxlength="64"/>
                        </div>
                    </div>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--<div class="form-group">--%>
                    <%--<label class="col-sm-2 control-label">开单科室：</label>--%>
                    <%--<div class="col-sm-4">--%>
                    <%--<form:input path="newDept" htmlEscape="false" class="form-control"  maxlength="64" />--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">数量：</label>
                        <div class="col-sm-8">
                            <form:input  type="number" min="0" data-parsley-required="true"  path="amount" htmlEscape="false" class="form-control"  maxlength="11" />
                        </div>
                    </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">单价：</label>

                <div class="col-sm-8">
                    <form:input path="price" htmlEscape="false" readonly="true" class="form-control"/>
                </div>
            </div>
            <div class="form-group">
            <label class="col-sm-4 control-label">总价：</label>
            <div class="col-sm-8">
            <form:input path="sumPrice" htmlEscape="false" readonly="true" class="form-control"  />
            </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">医生说明：</label>

                <div class="col-sm-8">
                    <form:input path="doctInstruction" htmlEscape="false" class="form-control" maxlength="100"/>
                </div>
            </div>
            <%--<div class="form-group">--%>
            <%--<label class="col-sm-2 control-label">是否皮试：</label>--%>
            <%--<div class="col-sm-4">--%>
            <%--<form:input path="isSkin" htmlEscape="false" class="form-control"  />--%>
            <%--</div>--%>
            <%--</div>--%>
            <%--<div class="form-group">--%>
            <%--<label class="col-sm-2 control-label">机构id：</label>--%>
            <%--<div class="col-sm-4">--%>
            <%--<form:input path="orgId" htmlEscape="false" class="form-control"  maxlength="64" />--%>
            <%--</div>--%>
            <%--</div>--%>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input id="btnSubmit"
                           onclick="saveSub('treatProjectItem','inputForm','${ctx}/treatProjectItem/treatProjectItem/save',
                                   '${ctx}/treatProjectItem/treatProjectItem/indexTreat?type=2&id=${treatProjectItem.applyId}','${treatProjectItem.applyId}')"
                           class="btn btn-primary" type="button" value="保 存">&nbsp;
                    <input id="btnCancel" class="btn" type="button" value="返 回">
                </div>
            </div>
            </form:form>
        </div>

</div>
</section>
</div>